// pages/me/me.js
const app = getApp()

Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		// avatarUrl: './user-unlogin.png',
		// userInfo: {},
		logged: false,
		funs:[
			{
				name:"学习充电",
				imgPath:"../../images/knowledge.png",
				itemid:"knowledge"
			},
			{
				name:"附近银行",
				imgPath: "../../images/bank.png",
				itemid: "bank"
			},
			{
				name: "汇率计算器",
				imgPath: "../../images/calculator.png",
				itemid: "rate"
			},
			{
				name: "客服",
				imgPath: "../../images/service.png",
				itemid: "service"
			},
			{
				name: "意见反馈",
				imgPath: "../../images/feedback.png",
				itemid: "feedback"
			},

		]
	},

	fun:function(e){
		console.log("点击了客服",e)
	},

	navigateToDetail:function(e){
		let itemid = e.currentTarget.dataset.itemid;
		if (itemid == "knowledge") {
			wx.navigateTo({
				url: './knowledge/knowledge'
			})
		} else if (itemid == "bank") {
			wx.navigateTo({
				url: './map/map'
			})
		} else if(itemid == "rate") {
			wx.navigateTo({
				url: './rate/rate'
			})
		} else if (itemid == "service") {
			wx.navigateTo({
				url: './service/service'
			})
		} else if (itemid == "feedback"){
			wx.navigateTo({
				url: './feedback/feedback'
			})
		}
		
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		wx.showLoading({
			title: '加载中',
		})
		setTimeout(function () {
			wx.hideLoading()
		}, 1000)

		// let userInfo = app.globalData.userInfo
		// console.log(userInfo)
		// this.setData({
		// 	avatarUrl: userInfo.avatarUrl,
		// 	nickName:userInfo.nickName
		// })

		// 获取用户信息
		wx.getSetting({
			success: res => {
				if (res.authSetting['scope.userInfo']) {
					wx.getUserInfo({
						success: res => {
							this.setData({
								avatarUrl: res.userInfo.avatarUrl,
								nickName:res.userInfo.nickName
							})
						}
					})
					
				}
			}
		})
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {
		return{
			title:"大学生记账本",
			desc:"方便快捷的记账小程序",
			path:"/pages/welcome/welcome"
		}
	}
})